<template>
  <div class="tab-bar-item" @click="itemClick">
    <h2>{{message}}</h2>
    <router-link to="/home" class="tab-bar-item">
      <div v-if="!isActive">
        <slot name="item-icon"></slot>
      </div>
      <div v-else>
        <slot name="item-active-icon"></slot>
      </div>
      <div :class="{active:isActive}">
        <slot name="item-text"></slot>
      </div>
    </router-link>
  </div>
</template>

<script>
export default {
  name: "TabBarItem",
  props: {
    path: { type: String },
    message: { type: String }
  },
  data() {
    return {
      isActive: true
    };
  },
  methods: {
    itemClick() {
      this.$router.push({ path: this.path });
    }
  },
  components: {},
  computed: {},
  watch: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  updated() {}, //生命周期 - 更新之后
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less'>
//@import url(); 引入公共css类
.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  // height: 49px;
  text-decoration: none;
  // font-size: 0;
  img {
    width: 24px;
  }
  span {
    font-size: 12px;
    color: #666;
    &.active {
      color: #f0d;
    }
  }
}
</style>

